﻿var EstateList = {};

$(function () {
    var realJson = $.parseJSON($("#hidSearchJsonDefault").attr('myjson'));
    var data = dataBind.getRealDataByType(114);
    if ($("#hidPermissions").val().indexOf("Property.DataEstates.Search-All") == -1) {
        for (var i = 0; i < data.length; i++) {
            if (data[i].ItemCode != "50") {
                if (realJson == null) {
                    if (data[i].ItemCode == "10") {
                        $("#txtDistrictTypeKeyId").val(data[i].ItemValue);
                        $("#txtDistrictType").val(data[i].ItemText);
                        $("#txtDistrictTypeCode").val(data[i].ItemCode);
                        $("#txtIsSecondProperty").val(true);
                        $("#districtType").append('<li>|</li><li class="current"><a class="disType" keyId="' + data[i].ItemValue + '" code="' + data[i].ItemCode + '" onclick="changeDistrict(\'' + data[i].ItemValue + '\',\'' + data[i].ItemText + '\',\'' + data[i].ItemCode + '\',this)">' + data[i].ItemText + '</a></li>');
                    }
                    else {
                        $("#districtType").append('<li>|</li><li><a class="disType" keyId="' + data[i].ItemValue + '"  code="' + data[i].ItemCode + '" onclick="changeDistrict(\'' + data[i].ItemValue + '\',\'' + data[i].ItemText + '\',\'' + data[i].ItemCode + '\',this)">' + data[i].ItemText + '</a></li>');
                    }
                } else {
                    if (data[i].ItemValue == realJson.DistrictType) {
                        if (data[i].ItemCode == "10") {
                            $("#txtIsSecondProperty").val(true);
                        }
                        $("#txtDistrictTypeKeyId").val(data[i].ItemValue);
                        $("#txtDistrictType").val(data[i].ItemText);
                        $("#txtDistrictTypeCode").val(data[i].ItemCode);
                        $("#districtType").append('<li>|</li><li class="current"><a class="disType" keyId="' + data[i].ItemValue + '" code="' + data[i].ItemCode + '"  onclick="changeDistrict(\'' + data[i].ItemValue + '\',\'' + data[i].ItemText + '\',\'' + data[i].ItemCode + '\',this)">' + data[i].ItemText + '</a></li>');
                    } else if (data[i].ItemCode == "10") {
                        $("#txtIsSecondProperty").val(true);
                        $("#txtDistrictType").val(data[i].ItemText);
                        $("#txtDistrictTypeKeyId").val(data[i].ItemValue);
                        $("#txtDistrictTypeCode").val(data[i].ItemCode);
                        $("#districtType").append('<li>|</li><li class="current"><a class="disType" keyId="' + data[i].ItemValue + '"  code="' + data[i].ItemCode + '"  onclick="changeDistrict(\'' + data[i].ItemValue + '\',\'' + data[i].ItemText + '\',\'' + data[i].ItemCode + '\',this)">' + data[i].ItemText + '</a></li>');
                    } else {
                        $("#districtType").append('<li>|</li><li><a class="disType" keyId="' + data[i].ItemValue + '"  code="' + data[i].ItemCode + '"  onclick="changeDistrict(\'' + data[i].ItemValue + '\',\'' + data[i].ItemText + '\',\'' + data[i].ItemCode + '\',this)">' + data[i].ItemText + '</a></li>');
                    }
                }
            }
        }
    } else {
        for (var i = 0; i < data.length; i++) {
            if (realJson == null) {
                if (data[i].ItemCode == "10") {
                    $("#txtDistrictTypeKeyId").val(data[i].ItemValue);
                    $("#txtDistrictType").val(data[i].ItemText);
                    $("#txtDistrictTypeCode").val(data[i].ItemCode);
                    $("#txtIsSecondProperty").val(true);
                    $("#districtType").append('<li>|</li><li class="current"><a class="disType" keyId="' + data[i].ItemValue + '"  code="' + data[i].ItemCode + '"  onclick="changeDistrict(\'' + data[i].ItemValue + '\',\'' + data[i].ItemText + '\',\'' + data[i].ItemCode + '\',this)">' + data[i].ItemText + '</a></li>');
                }
                else {
                    $("#districtType").append('<li>|</li><li><a class="disType" keyId="' + data[i].ItemValue + '" code="' + data[i].ItemCode + '"  onclick="changeDistrict(\'' + data[i].ItemValue + '\',\'' + data[i].ItemText + '\',\'' + data[i].ItemCode + '\',this)">' + data[i].ItemText + '</a></li>');
                }
            } else {
                if (data[i].ItemValue == realJson.DistrictType) {
                    if (data[i].ItemCode == "10") {
                        $("#txtIsSecondProperty").val(true);
                    }
                    $("#txtDistrictTypeKeyId").val(data[i].ItemValue);
                    $("#txtDistrictType").val(data[i].ItemText);
                    $("#txtDistrictTypeCode").val(data[i].ItemCode);
                    $("#districtType").append('<li>|</li><li class="current"><a class="disType" keyId="' + data[i].ItemValue + '"  code="' + data[i].ItemCode + '"  onclick="changeDistrict(\'' + data[i].ItemValue + '\',\'' + data[i].ItemText + '\',\'' + data[i].ItemCode + '\',this)">' + data[i].ItemText + '</a></li>');
                } else if (data[i].ItemCode == "10") {
                    $("#txtIsSecondProperty").val(true);
                    $("#txtDistrictTypeKeyId").val(data[i].ItemValue);
                    $("#txtDistrictType").val(data[i].ItemText);
                    $("#txtDistrictTypeCode").val(data[i].ItemCode);
                    $("#districtType").append('<li>|</li><li class="current"><a class="disType" keyId="' + data[i].ItemValue + '"  code="' + data[i].ItemCode + '"  onclick="changeDistrict(\'' + data[i].ItemValue + '\',\'' + data[i].ItemText + '\',\'' + data[i].ItemCode + '\',this)">' + data[i].ItemText + '</a></li>');
                } else {
                    $("#districtType").append('<li>|</li><li><a class="disType" keyId="' + data[i].ItemValue + '"  code="' + data[i].ItemCode + '"  onclick="changeDistrict(\'' + data[i].ItemValue + '\',\'' + data[i].ItemText + '\',\'' + data[i].ItemCode + '\',this)">' + data[i].ItemText + '</a></li>');
                }
            }
        }
    }
    //加载及时搜索标签方法
    EstateList.loadTagData = function (eleId, data, tagName) {
        for (var i = 0; i < data.length; i++) {
            $("#" + eleId).append('<label class="l"><input type="checkbox" name="' + tagName + '" value="' + data[i].ItemValue + '" text="' + data[i].ItemText + '" />' + data[i].ItemText + '</label>');
        }
    };

    //初始化EstateList的属性或方法Start  
    EstateList.getEstateUrl = function () {
        var districtKeyIds = '', areaKeyIds = '', isHouse = '', estateName = [];
        $('#hidDistrict input[type=checkbox]:checked').each(function () {
            districtKeyIds += $(this).val() + ',';
        });
        $('#hidArea input[type=checkbox]:checked').each(function () {
            areaKeyIds += $(this).val() + ',';
        });
        estateName = $('#txtEstateNames').val().split('+');
        isHouse = $('#IsHouse').val();
        return '/property/estates-for-region-keyids-obtain-ajax?DistrictKeyIds=' + districtKeyIds.substr(0, districtKeyIds.length - 1) + '&AreaKeyIds=' + areaKeyIds.substr(0, areaKeyIds.length - 1) + '&EstateName=' + escape(estateName[estateName.length - 1]) + '&IsHouse=' + isHouse;
    };
    //初始化EstateList的属性或方法End


    //初始化build的属性或方法Start  
    EstateList.getbuildUrl = function () {
        return '/property/building-for-estate-obatin-ajax?EstateName=' + escape($("#txtEstateNames").val()) + '&BuildName=' + $("#btnBuilding").val();
    };
    //初始化build的属性或方法End


    //楼盘自动完成及赋值隐藏域
    $("#txtEstateNames").autocomplete(EstateList.getEstateUrl, {
        width: 260,
        max: 1000,
        Default: 1,
        selectFirst: false,
        cacheLength: 0,
        multiple: true,
        multipleSeparator: '+',
        formatItem: function (row) {
            return row.EstateFullName;
        },
        formatResult: function (row) {
            return row.EstateName;

        }
    }).result(function (a, b) {
        $("#txtEstateNames").attr('isexistbuild', 'true');
        $("#txtHouseNo").removeAttr("readonly");
        $("#btnBuilding").removeAttr("readonly");
    });

    $('#txtEstateNames').bind('change', function () {
        $('#btnBuilding').val('');
        $("#hidBuildKeyId").val('');
        $('#hidBuilding ul').html('');
        $(this).attr('isexistbuild', 'true');
        if ($(this).val() == "") {
            $("#txtHouseNo").attr("readonly", "readonly").val("");
            $("#btnBuilding").attr("readonly", "readonly").val("");
        }
        else //楼盘 栋座 模糊查询 lixn 2016-04-21
        {
            $("#btnBuilding").removeAttr("readonly");
            $("#txtHouseNo").removeAttr("readonly");
        }

    });


    //栋座自动完成及赋值隐藏域
    $("#btnBuilding").autocomplete(EstateList.getbuildUrl, {
        width: 260,
        max: 1000,
        Default: 1,
        selectFirst: false,
        cacheLength: 0,
        multiple: true,
        clickMode: true,
        minChars: 0,
        formatItem: function (row) {
            return row.BuildingName;
        },
        formatResult: function (row) {

            return row.BuildingName;
        }
    }).result(function (a, b) {
        $("#hidBuildKeyId").val(b.KeyId);
    });

    //是否是点击submit，主要判断是否生成json
    EstateList.isSubmit = function (element) {
        $(element).attr('isSubmitValue', 'true');
    };

    //保存搜索条件
    EstateList.saveSearchCondition = function (element, saveSearchType) {
        var reqData = {
            'SaveSearchType': saveSearchType,
            'Json': $('#divJson').html()
        };
        if (reqData.Json.length == 1010) {
            //如果等于这个1010错误，就先判断是否是正确的Json格式
            if (reqData.Json.indexOf("DistrictNames") > 0 && reqData.Json.indexOf("EstateNames") > 0
                && reqData.Json.indexOf("}") > 0) {
            }
            else {
                $.OKDialogAgency('<div class="tc">请选择至少一个搜索条件！</div>');
                return;
            }
        }
        $.AjaxAgency('/property/property-create-search-criteria-ajax', reqData, function (data) {
            if (data.indexOf('ok:') == 0) {
                $(element).css('display', 'none');
                $('#spanUsedQuota').css('display', '');
                var tempData = data.split(':')[1];
                $('#strUsedQuotaConut').html(tempData.split('-')[0]);
                $('#spanUsedQuota').attr('leavequota', tempData.split('-')[1]);
                $.OKDialogAgency('<div class="tc">保存成功！</div>');
            } else {
                $.OKDialogAgency('<div class="tc">保存失败！' + data + '</div>');
            }
        });
    };

    //显示保存搜索条件
    EstateList.btnShowSearchCondition = function (element, saveSearchType) {
        var reqData = {
            'SaveSearchType': saveSearchType
        };
        $.AjaxAgency('/property/property-search-condition-ajax', reqData, function (data) {
            if (data.indexOf('#Error*:') == 0) {
                $.OKDialogAgency('<div class="tc">' + data + '</div>');
            } else if (data == '0') {
                $.OKDialogAgency('<div class="tc">没有数据！</div>');
            } else {
                var tempJson = $.parseJSON(data);
                var tempTextValue = '';
                tempTextValue = EstateList.jsonValueConvertTxt(tempJson, saveSearchType);
                $.artDialog({
                    id: 'dialogShowSearchCondition',
                    title: '我的找房条件',
                    lock: true,
                    width: 600,
                    content: tempTextValue
                });
            }
        });
    };

    //将传入的json转换为对应的中文信息
    EstateList.jsonValueConvertTxt = function (jsonValue, saveSearchType) {
        var tempTextValue = '<div class="pop-box"><table class="data-table" id="tableSearchCondition"><tbody><tr><th>条件</th><th class="w80">操作</th></tr>';
        var tempInnerTextValue = "";

        for (var i = 0; i < jsonValue.length; i++) {
            for (var item in jsonValue[i]) {
                if (item == 'Json' && jsonValue[i].Source == saveSearchType) {
                    var realJson = $.parseJSON(jsonValue[i][item]);
                    tempTextValue += '<tr id="tr' + jsonValue[i].KeyId + '"><td class="tl"><span class="color-12" style="display:inline-block;width:auto !important;max-width:500px;width:500px;" onclick="EstateList.submitSaveCondition(this);" myjson=\'' + jsonValue[i][item] + '\'>';
                    tempInnerTextValue = "";

                    for (var item2 in realJson) {
                        if (item2 == "PropertyDateType") { //房源日期类型
                            if (!realJson.PropertyDateFrom && !realJson.PropertyDateTo) {
                                continue;
                            }
                        }
                        if (realJson[item2] != null && realJson[item2] != '-1' && realJson[item2] != '') {
                            tempInnerTextValue += EstateList.jsonSwitch(item2, realJson[item2]);
                        }
                    }

                    if (tempInnerTextValue != "") {
                        tempTextValue += tempInnerTextValue;
                    } else {
                        tempTextValue += '<div>空搜索条件</div>';
                    }

                    tempTextValue += '</span></td><td><a onclick="EstateList.delSearchCondition(\'' + jsonValue[i].KeyId + '\',' + saveSearchType + ');">删除</a> ';
                    if (jsonValue[i].IsDefault) {
                        tempTextValue += '<span keyid="' + jsonValue[i].KeyId + '" type="setdefault"><a onclick="EstateList.cancelDefault(\'' + jsonValue[i].KeyId + '\',this);">取消默认</a></span>';
                    }
                    else {
                        tempTextValue += '<span keyid="' + jsonValue[i].KeyId + '" type="setdefault"><a onclick="EstateList.setDefault(\'' + jsonValue[i].KeyId + '\',this);">设置默认</a></span>';
                    }
                    tempTextValue += '</td></tr>';

                }
            }
        }
        tempTextValue += '</tbody></table></div>';
        return tempTextValue;
    };

    //数据匹配为（json转换为对应的中文信息）
    EstateList.jsonSwitch = function (itemName, itemValue) {
        var houseDirectionList = '', filterPropertyTypeValue, filterExpertTransactionValue;
        for (var i = 0; i < PropertyFilterGrouped.PropertySearchTag.length; i++) {
            if (PropertyFilterGrouped.PropertySearchTag[i].Name == "朝向") {
                houseDirectionList = PropertyFilterGrouped.PropertySearchTag[i];
            }
            if (PropertyFilterGrouped.PropertySearchTag[i].Name == "建筑类型") {
                filterPropertyTypeValue = PropertyFilterGrouped.PropertySearchTag[i];
            }
            if (PropertyFilterGrouped.PropertySearchTag[i].Name == "行家成交") {
                filterExpertTransactionValue = PropertyFilterGrouped.PropertySearchTag[i];
            }
        }
        switch (itemName) {
            case "FilterContent":
                return itemValue.replace(/&lt;/g, '<').replace(/&gt;/g, '>');
            case 'DistrictTypeName':
                return '<div><label class="red">城区类型：</label>' + itemValue + '</div>';
            case 'DistrictNames':
                return '<div><label class="red">城区：</label>' + itemValue + '</div>';
            case 'AreaNames':
                return '<div><label class="red">片区：</label>' + itemValue + '</div>';
            case 'EstateNames':
                return '<div><label class="red">楼盘名称：</label>' + itemValue + '</div>';
            case 'BuildingNames':
                return '<div><label class="red">栋座：</label>' + itemValue + '</div>';
            case 'HouseNo':
                return '<div><label class="red">房号：</label>' + itemValue + '</div>';
            case 'IncludedPropertyFilterHouseDirectionValue':
                var temp = '';
                var temphouseDirection = itemValue.split(',');
                for (var k = 0; k < temphouseDirection.length; k++) {
                    for (var j = 0; j < houseDirectionList.Items.length; j++) {
                        if (temphouseDirection[k] == houseDirectionList.Items[j].ItemValue) {
                            temp += houseDirectionList.Items[j].ItemText + ',';
                        }
                    }
                }

                return '<div><label class="red">朝向：</label>' + temp + '</div>';
            case 'IncludedPropertyFilterPropertyTypeValue':
                var temp2 = '';
                var temFilterPropertyType = itemValue.split(',');
                for (var k = 0; k < temFilterPropertyType.length; k++) {
                    for (var j = 0; j < filterPropertyTypeValue.Items.length; j++) {
                        if (temFilterPropertyType[k] == filterPropertyTypeValue.Items[j].ItemValue) {
                            temp2 += filterPropertyTypeValue.Items[j].ItemText + ',';
                        }
                    }
                }
                return '<div<label class="red">建筑类型：</label>' + temp2 + '</div>';
            case "ExpertTransaction":
                var tempValue = '';
                var temFilterExpertTransaction = itemValue.split(',');
                for (var i = 0; i < temFilterExpertTransaction.length; i++) {
                    for (var j = 0; j < filterExpertTransactionValue.Items.length; j++) {
                        if (temFilterExpertTransaction[i] == filterExpertTransactionValue.Items[j].ItemValue) {
                            tempValue += filterExpertTransactionValue.Items[j].ItemText + ',';
                        }
                    }
                }
                return '<div><label class="red">行家成交：</label>' + tempValue;
            case 'IncludedPropertyStatus':
                var temp = '';
                var temPropertyStatus = itemValue.split(',');
                for (var n = 0; n < temPropertyStatus.length; n++) {
                    for (var k = 0; k < PropertyFilterGrouped.PropertyStatus.length; k++) {
                        if (temPropertyStatus[n] == PropertyFilterGrouped.PropertyStatus[k].Value) {
                            temp += PropertyFilterGrouped.PropertyStatus[k].Name + ',';
                        }
                    }
                }

                return '<div><label class="red">房源状态：</label>' + temp + '</div>';
            case 'SalePriceFromAndTo':
                return '<div><label class="red">售价：</label>' + itemValue + '</div>';
            case 'RentPriceFromAndTo':
                return '<div><label class="red">租价：</label>' + itemValue + '</div>';
            case 'SquareFromAndTo':
                return itemValue.replace(/&lt;/g, '<').replace(/&gt;/g, '>');
            case 'PropertyDateType':
                return '<div><label class="red">房源日期类型：</label>' + $('#cmbPropertyDateType [value=' + itemValue + ']').text() + '</div>';
            case 'PropertyDateFromAndTo':
                return '<div><label class="red">房源日期：</label>' + itemValue + '</div>';
            case 'TrustType':
                return '<div><label class="red">交易类型：</label>' + $('#cmbTrustType [value=' + itemValue + ']').text() + '</div>';
            case 'EstateBuildingName':
                return '<div><label class="red">楼盘 栋座：</label>' + itemValue + '</div>';
            case 'FloorFromAndTo':
                return itemValue.replace(/&lt;/g, '<').replace(/&gt;/g, '>');
            case 'PropertyRightNatureKeyId':
                return '<div><label class="red">产权性质：</label>' + $('#btnPropertyOption [value=' + itemValue + ']').text() + '</div>';
            case 'DecorationSituationKeyId':
                return '<div><label class="red">装修情况：</label>' + $('#selDecorationSituation [value=' + itemValue + ']').text() + '</div>';
            case 'PropertyUsageKeyId':
                return '<div><label class="red">房屋用途：</label>' + $('#selHouseUse [value=' + itemValue + ']').text() + '</div>';
            case 'PropertySituationKeyId':
                return '<div><label class="red">房源现状：</label>' + $('#selHouseStatus [value=' + itemValue + ']').text() + '</div>';
            case 'BpropertyTypeNames':
                return '<div><label class="red">房型：</label>' + itemValue + '</div>';
            case 'PropertyChiefDeptName':
                return '<div><label class="red">房源所属人部门：</label>' + itemValue + '</div>';
            case 'PropertyChiefName':
                return '<label class="red">房源所属人：</label>' + itemValue;
            case "AuditStatus":
                return '<label class="red">审核状态：</label>' + $('#cmbAuditStatus [value=' + itemValue + ']').text();
            case "IsHouse":
                return '<label class="red">住宅类型：</label>' + $('#IsHouse [value=' + itemValue + ']').text();
            default:
                var tempNoMatch = ['Filter', 'FilterType', 'DistrictKeyIds', 'AreaKeyIds', 'PropertyDateFrom', 'PropertyDateTo', 'FloorFrom', 'FloorTo', 'SquareFrom', 'SquareTo', 'SalePriceFrom', 'SalePriceTo', 'RentPriceFrom', 'RentPriceTo', 'BpropertyTypeKeyIds', 'BroomTypeKeyIds', 'PropertyChiefDeptKeyId', 'PropertyChiefKeyId', 'PropertySquareType', 'DistrictType', 'DistrictTypeCode'];
                var noMatchValue = false;
                for (var m = 0; m < tempNoMatch.length; m++) {
                    if (itemName == tempNoMatch[m]) {
                        noMatchValue = true;
                    }
                }
                if (noMatchValue) {
                    return '';
                }
                return '<div><label class="red">漏匹配字段: </label>' + itemName + '</div>';
        }
    };

    //表单验证
    agencyVerify.nonnegativeIntInput("input[isint=1]", true);
    agencyVerify.greaterThanEqualZero("input[iszhengfu=1]", true);
    //删除保存的搜索条件
    EstateList.delSearchCondition = function (keyId, saveSearchType) {
        //if (!confirm('您确定要删除当前保存条件吗？')) {
        //    return false;
        //}
        $.OKCancelDialogAgency('<div class="tc">您确定要删除此条找房条件吗？</div>', '提示', true, function () {
            var reqData = {
                'keyId': keyId,
                'SaveSearchType': saveSearchType
            };
            $.AjaxAgency('/property/property-search-criteria-batch-remove-ajax', reqData, function (data) {
                if (data.indexOf('ok:') == 0) {
                    if (data.split(':')[1] <= 0) {
                        $('#spanUsedQuota').css('display', 'none');
                    }
                    var tempData = data.split(':')[1];
                    $('#strUsedQuotaConut').html(tempData.split('-')[0]);
                    $('#spanUsedQuota').attr('leavequota', tempData.split('-')[1]);

                    $.artDialog({
                        time: 1,
                        content: '<div class="tc">删除成功！</div>'
                    });
                    $('#tr' + keyId).remove();
                    //当保存条件数目为0时，隐藏".info-list-other"
                    if ($('#strUsedQuotaConut').html() == "0") {
                        $(".info-list-other").hide();
                    }
                } else {
                    $.OKDialogAgency('<div class="tc">' + data + '</div>');
                }
            });
            art.dialog({ id: "dialogShowSearchCondition" }).close();
        }, true);
    };

    //提交保存条件查询数据
    EstateList.submitSaveCondition = function (element) {
        $("#districtType li").removeClass("current");
        $("#btnClear").click();
        var realJson = $.parseJSON($(element).attr('myjson'));
        //城区数据
        $('#hidDistrict ul input[name=chbhidDistrict]:checked').each(function () {
            $(this).removeAttr('checked');
            $('#txtDistrict').val('');
        });
        if (realJson.DistrictType) {
            $(".disType").each(function () {
                if ($(this).attr("keyId") == realJson.DistrictType) {
                    $(this).parent().addClass("current");
                }
            });

            $("#txtDistrictTypeKeyId").val(realJson.DistrictType);
        } else {
            $(".disType").each(function () {
                if ($(this).attr("code") == "10") {
                    $(this).parent().addClass("current");
                    $("#txtDistrictTypeKeyId").val($(this).attr("keyId"));
                }
            });
        }

        if (realJson.DistrictTypeCode == "10" || realJson.DistrictTypeCode == undefined) {
            $("#txtIsSecondProperty").val(true);
        } else {
            $("#txtIsSecondProperty").val(false);
        }
        if (realJson.DistrictKeyIds) {
            if (realJson.DistrictType == $("#txtDistrictTypeKeyId").val()) {
                var districtKeyIds = [];
                var tempDistrictKeyIds = realJson.DistrictKeyIds.split(',');
                $('#hidDistrict ul input[name=chbhidDistrict]').each(function () {
                    for (var m = 0; m < tempDistrictKeyIds.length; m++) {
                        if ($(this).val() == tempDistrictKeyIds[m]) {
                            $(this).attr('checked', 'checked');
                            districtKeyIds.push($(this).val());
                        }
                    }
                });
                $('#txtDistrict').val(realJson.DistrictNames);

                //片区
                $('#hidArea ul input[name=chbhidArea]:checked').each(function () {
                    $(this).removeAttr('checked');
                    // $('#txtArea').val('片区');
                    $('#txtArea').val('');
                });
                if (realJson.AreaKeyIds) {
                    //片区数据加载 
                    var temstr = '', selectedKeyIds = realJson.AreaKeyIds.split(','), dataArray = realJson.DistrictKeyIds.split(',');
                    for (var j = 0; j < dataArray.length; j++) {
                        for (var i = 0; i < Regions.RegionItems.length; i++) {
                            if (Regions.RegionItems[i].ParentId == dataArray[j]) {
                                var isCirculation = false;
                                for (var k = 0; k < selectedKeyIds.length; k++) {
                                    if (Regions.RegionItems[i].Id == selectedKeyIds[k]) {
                                        temstr += '<li style="line-height:150%"><label class="red"><input style="margin-right:10px;" name="chbhidArea" type="checkbox" checked="checked" text="' + Regions.RegionItems[i].Name + '" value ="' + Regions.RegionItems[i].Id + '" parentid="' + Regions.RegionItems[i].ParentId + '" />' + Regions.RegionItems[i].Name + '</label></li>';

                                        isCirculation = true;
                                    }
                                }

                                if (isCirculation) {
                                    continue;
                                }
                                temstr += '<li style="line-height:150%"><label><input style="margin-right:10px;" name="chbhidArea" type="checkbox" text="' + Regions.RegionItems[i].Name + '" value ="' + Regions.RegionItems[i].Id + '" parentid="' + Regions.RegionItems[i].ParentId + '" />' + Regions.RegionItems[i].Name + '</label></li>';
                            }
                        }
                    }
                    $('#hidArea ul').append(temstr);
                    $('#txtArea').val(realJson.AreaNames);
                } else {
                    multipleRegionsCheckBox('#txtArea', 'hidArea', 2, districtKeyIds, ['propertyStatusSelect', 'roomType', 'propertyType', 'hidDistrict'], '');//片区数据加载
                }
            }
        }

        $('#txtEstateNames').val(realJson.EstateNames);
        $('#txtEstateNames').attr('isexistbuild', 'true');
        $('#btnBuilding').val(realJson.BuildingNames);
        $('#txtHouseNo').val(realJson.HouseNo);
        if ($('#txtEstateNames').val()) {
            $('#btnBuilding').removeAttr("readonly");
            $('#txtHouseNo').removeAttr("readonly");
        }
        $('#cmbTrustType').val(realJson.TrustType).change();
        $('#txtSalePriceFrom').val(realJson.SalePriceFrom);
        $('#txtSalePriceTo').val(realJson.SalePriceTo);
        $('#txtRentPriceFrom').val(realJson.RentPriceFrom);
        $('#txtRentPriceTo').val(realJson.RentPriceTo);
        if (realJson.SquareFrom || realJson.SquareTo) {
            $('#selPropertySquareType').val(realJson.PropertySquareType).change();
        }
        $('#txtSquareFrom').val(realJson.SquareFrom);
        $('#txtSquareTo').val(realJson.SquareTo);
        $('#btnFloorFrom').val(realJson.FloorFrom);
        $('#btnFloorTo').val(realJson.FloorTo);
        $('#btnPropertyOption').val(realJson.PropertyRightNatureKeyId);
        $('#selDecorationSituation').val(realJson.DecorationSituationKeyId);
        $('#selHouseUse').val(realJson.PropertyUsageKeyId);
        //不限日期
        if (realJson.PropertyDateFrom || realJson.PropertyDateTo) {
            $('#cmbPropertyDateType').val(realJson.PropertyDateType).change();
        }
        $('#txtPropertyDateFrom').val("");
        $('#txtPropertyDateTo').val("");
        if (realJson.PropertyDateFrom) {
            $('#txtPropertyDateFrom').val(realJson.PropertyDateFrom.split("T")[0]);
        }
        if (realJson.PropertyDateTo) {
            $('#txtPropertyDateTo').val(realJson.PropertyDateTo.split("T")[0]);
        }

        $('#selHouseStatus').val(realJson.PropertySituationKeyId);
        //房源状态
        $('input[name=chbpropertyStatusSelect]:checked').each(function () {
            $(this).removeAttr('checked');
            $('#txtPropertyStatus').val('');
        });
        if (realJson.IncludedPropertyStatus) {
            var tempStatusText = '';
            $('input[name=chbpropertyStatusSelect]').each(function () {
                var tempStatus = realJson.IncludedPropertyStatus.split(',');
                for (var m = 0; m < tempStatus.length; m++) {
                    if ($(this).val() == tempStatus[m]) {
                        $(this).attr('checked', 'checked');
                        tempStatusText += m < tempStatus.length - 1 ? $(this).attr('text') + ',' : $(this).attr('text');
                    }
                }

            });
            $('#txtPropertyStatus').val(tempStatusText);
        }
        //房型
        $('#propertyType input[name=chbpropertyType]:checked').each(function () {
            $(this).removeAttr('checked');
            $('#txtPropertyType').val('');
        });
        if (realJson.BpropertyTypeKeyIds) {
            $('#propertyType input[name=chbpropertyType]').each(function () {
                var tempPropertyTypeKeyIds = realJson.BpropertyTypeKeyIds.split(',');
                for (var m = 0; m < tempPropertyTypeKeyIds.length; m++) {
                    if ($(this).val() == tempPropertyTypeKeyIds[m]) {
                        $(this).attr('checked', 'checked');
                    }
                }
            });
            $('#txtPropertyType').val(realJson.BpropertyTypeNames);
        }

        //不限条件
        if (realJson.FilterType && realJson.Filter) {
            $('#cmbFilterType').val(realJson.FilterType);
            $('#txtFilter').val(realJson.Filter);
        }

        //朝向
        var tempHouseDirectionCheckbox = $('input[name=HouseDirection]');
        tempHouseDirectionCheckbox.each(function () {
            $(this).removeAttr('checked');
        });
        if (realJson.IncludedPropertyFilterHouseDirectionValue) {
            var tempHouseDirection = realJson.IncludedPropertyFilterHouseDirectionValue.split(',');
            for (var k = 0; k < tempHouseDirection.length; k++) {
                tempHouseDirectionCheckbox.each(function () {
                    if ($(this).val() == tempHouseDirection[k]) {
                        $(this).attr('checked', 'checked');
                    }
                });
            }
        }
        //建筑类型
        var tempFilterPropertyTypeCheckbox = $('input[name=PropertyType]');
        tempFilterPropertyTypeCheckbox.each(function () {
            $(this).removeAttr('checked');
        });
        if (realJson.IncludedPropertyFilterPropertyTypeValue) {
            var tempFilterPropertyType = realJson.IncludedPropertyFilterPropertyTypeValue.split(',');
            for (var k = 0; k < tempFilterPropertyType.length; k++) {
                tempFilterPropertyTypeCheckbox.each(function () {
                    if ($(this).val() == tempFilterPropertyType[k]) {
                        $(this).attr('checked', 'checked');
                    }
                });
            }
        }
        //住宅类型
        if (realJson.IsHouse != "") {
            $('#IsHouse').val(realJson.IsHouse);
        }
        //盘源归属
        if (realJson.PropertyChiefDeptKeyId) {
            $('#txtDepartmentName').val(realJson.PropertyChiefDeptName);
            $('#hidDepartmentId').val(realJson.PropertyChiefDeptKeyId);
            $('#txtDepartmentName').css('color', '');
        }
        if (realJson.PropertyChiefKeyId) {
            $('#txtEmployeeName').val(realJson.PropertyChiefName);
            $('#hidUserId').val(realJson.PropertyChiefKeyId);
            $('#txtEmployeeName').css('color', '');
        }
        if (art.dialog.get('dialogShowSearchCondition')) {
            art.dialog.get('dialogShowSearchCondition').close();
        }
        $("#propertyboolTag input[type=checkbox]").attr("checked", false);
        $('#searchForm').submit();
    };

    EstateList.cancelDefault = function (keyid, el) {
        var reqData = {
            'KeyId': keyid
        };
        $.AjaxAgency('/property/property-default-search-criteria-cancel-ajax', reqData, function (data) {
            if (data == "ok") {
                $(el).parent().html('<a onclick="EstateList.setDefault(\'' + keyid + '\',this);">设置默认</a>');
            } else {
                $.OKDialogAgency('<div class="tc">' + data + '</div>');
            }
        });
    }
    EstateList.setDefault = function (keyId, el) {
        var temspan = $(el).parent()[0];
        var reqData = {
            'KeyId': keyId
        };
        $.AjaxAgency('/property/property-default-search-criteria-ajax', reqData, function (data) {
            if (data == "ok") {
                $("#tableSearchCondition span[type=setdefault]").each(function () {
                    if (this == temspan) {
                        $(this).html('<a onclick="EstateList.cancelDefault(\'' + keyId + '\',this);">取消默认</a>')
                    }
                    else if ($(this).text() == "取消默认") {
                        $(this).html('<a onclick="EstateList.setDefault(\'' + $(this).attr("keyid") + '\',this);">设置默认</a>');
                    }
                });
            } else {
                $.OKDialogAgency('<div class="tc">' + data + '</div>');
            }
        });
    }
    //清空事件
    $('#btnClear').click(function () {

        $("#hidBuilding ul").html('');
        $('#spanDateTime,#PerformanceUserName').css('display', 'none');
        $("#hidDistrict ul").find("input[type=checkbox]").attr("checked", false);
        $("#hidArea ul").html('');
        $("#spanHouseDirection input[type=checkbox]").attr("checked", false);
        $("#spanPropertyType input[type=checkbox]").attr("checked", false);
        $('#propertyType input[name=chbpropertyType]').attr("checked", false);
        $('#roomType input[type=checkbox]').attr("checked", false);
        $('#txtDepartmentName').css('color', 'gray');
        $("#hidDepartmentId").val('');
        $('#txtEmployeeName').css('color', 'gray');
        $("#hidUserId").val('');
        $('#salespan').css('display', '');
        $('#Rentspan').css('display', '');
        var tempViewPattern = $("#hidViewPattern").val();
        setTimeout(function () { $('#hidViewPattern').val(tempViewPattern); }, 200);
        $("#txtHouseNo").attr("readonly", "readonly");
        //重置时清空排序字段和业绩声明
        $("#hiddenSortValue,#PerformanceUserKeyId,#PerformanceDepartmentKeyId").val("");
        $("#spanPropertyExpertTransaction input[type=checkbox]").attr("checked", false);
    });

    //selMore()
    $("#moresel").toggle(function () {
        $("#moresearch").show().addClass("db");
        $(".showsel").hide();
        $(".hidsel").show();
    }, function () {
        $("#moresearch").hide().removeClass("db");
        $(".showsel").show();
        $(".hidsel").hide();
    });

    $("#cmbTrustType").bind("change", function () {

        if (this.value == "5") {
            $('#txtRentPriceFrom').val('');
            $('#txtRentPriceTo').val('');
            $("#salespan").show();
            $("#Rentspan").hide();
            $("#Rentspan").addClass("ml20");
        }
        else if (this.value == "4") {
            $('#txtSalePriceFrom').val('');
            $('#txtSalePriceTo').val('');
            $("#salespan").hide();
            $("#Rentspan").show();
            $("#Rentspan").removeClass("ml20");
        }
        else {
            $("#salespan").show();
            $("#Rentspan").show();
            $("#Rentspan").addClass("ml20");
        }
    });


    //满五年等checkbox显示start
    var propertyboolTag = '', propertyContributionTag = '', myPropertyContributionTag = '', propertyboolCalcTag = '', managerRecommend = "",
        otherTag, videoTag = "", recommendTag = "", houseTag = "", hauntedHouseTag = "";
    for (var k = 0; k < SysParam.length; k++) {
        if (SysParam[k].ParameterType == '27') {
            propertyboolTag = [];
            videoTag = [];
            houseTag = [];
            hauntedHouseTag = [];
            for (var i = 0; i < SysParam[k].Items.length; i++) {
                if (SysParam[k].Items[i].ItemCode != "2000" && SysParam[k].Items[i].ItemCode != "2300"
                    && SysParam[k].Items[i].ItemCode != "2400" && SysParam[k].Items[i].ItemCode != "2500"
                    && SysParam[k].Items[i].ItemCode != "40" && SysParam[k].Items[i].ItemText != "凶宅")
                    propertyboolTag.push(SysParam[k].Items[i]);
                if (SysParam[k].Items[i].ItemCode == "2500") {
                    videoTag.push(SysParam[k].Items[i]);
                } if (SysParam[k].Items[i].ItemCode == "40") {
                    houseTag.push(SysParam[k].Items[i]);
                }
                if (SysParam[k].Items[i].ItemText == "凶宅")
                    hauntedHouseTag.push(SysParam[k].Items[i]);
            }
        }
        if (SysParam[k].ParameterType == '28') {
            propertyContributionTag = [];
            for (var i = 0; i < SysParam[k].Items.length; i++) {
                if (SysParam[k].Items[i].ItemCode != "30") {
                    propertyContributionTag.push(SysParam[k].Items[i]);
                }
            }
        }
        if (SysParam[k].ParameterType == '29') {
            managerRecommend = SysParam[k].Items;
        }
        if (SysParam[k].ParameterType == '39') {
            myPropertyContributionTag = SysParam[k].Items;
        }
        if (SysParam[k].ParameterType == '61') {
            propertyboolCalcTag = SysParam[k].Items;
        }
    }
    //追加免扰即时筛选项
    //去掉{ "ItemValue": "1", "ItemText": "集中带看房", "ItemCode": "other1", "ItemStatus": 1, "ExtendAttr": "", "FlagDefault": false },
    //  { "ItemValue": "3", "ItemText": "区经推荐", "ItemCode": "other3", "ItemStatus": 1, "ExtendAttr": "", "FlagDefault": false },
    // { "ItemValue": "4", "ItemText": "经理推荐", "ItemCode": "other4", "ItemStatus": 1, "ExtendAttr": "", "FlagDefault": false },
    var otherTagItems = [{
        "Items": [
         { "ItemValue": "7", "ItemText": "委托已审", "ItemCode": "other7", "ItemStatus": 1, "ExtendAttr": "", "FlagDefault": false },
         { "ItemValue": "5", "ItemText": "政府编号", "ItemCode": "other5", "ItemStatus": 1, "ExtendAttr": "", "FlagDefault": false },
         { "ItemValue": "6", "ItemText": "实勘复审", "ItemCode": "other6", "ItemStatus": 1, "ExtendAttr": "", "FlagDefault": false },
        { "ItemValue": "IsVideo", "ItemText": "视频房源", "ItemCode": "other8", "ItemStatus": 1, "ExtendAttr": "", "FlagDefault": false }
        ]
    }];
    otherTag = otherTagItems[0].Items;
    var recommendTagItems = [{
        "Items": [
         { "ItemValue": "3", "ItemText": "推荐房", "ItemCode": "other3", "ItemStatus": 1, "ExtendAttr": "", "FlagDefault": false },
         { "ItemValue": "2", "ItemText": "免扰房", "ItemCode": "other2", "ItemStatus": 1, "ExtendAttr": "", "FlagDefault": false }
        ]
    }];
    recommendTag = recommendTagItems[0].Items;
    //及时搜索数据加载Start
    var currentAction = $("#propertyboolTag").attr('showTag');
    if (currentAction == "war-zone") {
        //免扰房,集中带看，区经推荐，经理推荐
        EstateList.loadTagData('propertyboolTag', otherTag, 'otherTag');
        EstateList.loadTagData('propertyboolTag', recommendTag, 'otherTag');
        EstateList.loadTagData('propertyboolTag', houseTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', propertyContributionTag, 'PropertyContribution');
        EstateList.loadTagData('propertyboolTag', propertyboolTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', hauntedHouseTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', propertyboolCalcTag, 'PropertyboolCalcTag');

    } else if (currentAction == "area-manager-recommend") {
        //区经推荐，经理推荐
        var tempOtherTag = [];
        for (var i = 0; i < recommendTag.length; i++) {
            if (recommendTag[i].ItemCode == "other3") {
                tempOtherTag.push(recommendTag[i]);
            }
        }
        EstateList.loadTagData('propertyboolTag', tempOtherTag, 'otherTag');
        EstateList.loadTagData('propertyboolTag', houseTag, 'PropertyboolTag')
        //72小时新增放。30天租约到期房
        EstateList.loadTagData('propertyboolTag', propertyContributionTag, 'PropertyContribution');
        EstateList.loadTagData('propertyboolTag', propertyboolTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', hauntedHouseTag, 'PropertyboolTag')
        var tempPropertyboolCalcTag = [];
        for (var i = 0; i < propertyboolCalcTag.length; i++) {
            if (propertyboolCalcTag[i].ItemCode == "20") {
                continue;
            }
            tempPropertyboolCalcTag.push(propertyboolCalcTag[i]);
        }
        EstateList.loadTagData("propertyboolTag", tempPropertyboolCalcTag, "PropertyboolCalcTag");

    } else if (currentAction == "public-estate") {
        EstateList.loadTagData('propertyboolTag', houseTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', propertyContributionTag, 'PropertyContribution');
        EstateList.loadTagData('propertyboolTag', propertyboolTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', hauntedHouseTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', propertyboolCalcTag, 'PropertyboolCalcTag');
    } else if (currentAction == "my-sharing") {
        EstateList.loadTagData('propertyboolTag', otherTag, 'otherTag');
        EstateList.loadTagData('propertyboolTag', recommendTag, 'otherTag');
        EstateList.loadTagData('propertyboolTag', houseTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', myPropertyContributionTag, 'MyPropertyContribution');
        EstateList.loadTagData('propertyboolTag', propertyboolTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', hauntedHouseTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', propertyboolCalcTag, 'PropertyboolCalcTag');
    } else if (currentAction == "master-estate") {
        EstateList.loadTagData('propertyboolTag', otherTag, 'otherTag');
        EstateList.loadTagData('propertyboolTag', videoTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', recommendTag, 'otherTag');
        EstateList.loadTagData('propertyboolTag', houseTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', propertyContributionTag, 'PropertyContribution');
        EstateList.loadTagData('propertyboolTag', propertyboolTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', hauntedHouseTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', propertyboolCalcTag, 'PropertyboolCalcTag');
    } else if (currentAction == "my-favorite") {
        EstateList.loadTagData('propertyboolTag', otherTag, 'otherTag');
        EstateList.loadTagData('propertyboolTag', videoTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', recommendTag, 'otherTag');
        EstateList.loadTagData('propertyboolTag', houseTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', propertyContributionTag, 'PropertyContribution');
        EstateList.loadTagData('propertyboolTag', propertyboolTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', hauntedHouseTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', propertyboolCalcTag, 'PropertyboolCalcTag');
    } else if (currentAction == "my-recommend") {
        EstateList.loadTagData('propertyboolTag', videoTag, 'PropertyboolTag');
        //EstateList.loadTagData('propertyboolTag', houseTag, 'houseTag');
        var tempPropertyContributionTag = [];
        for (var i = 0; i < propertyContributionTag.length; i++) {
            if (propertyContributionTag[i].ItemCode == "40") {
                continue;
            }
            tempPropertyContributionTag.push(propertyContributionTag[i]);
        }
        EstateList.loadTagData('propertyboolTag', tempPropertyContributionTag, 'PropertyContribution');
        EstateList.loadTagData('propertyboolTag', propertyboolTag, 'PropertyboolTag');
        EstateList.loadTagData('propertyboolTag', hauntedHouseTag, 'PropertyboolTag');
        var tempPropertyboolCalcTag = [];
        for (var i = 0; i < propertyboolCalcTag.length; i++) {
            if (propertyboolCalcTag[i].ItemCode == "20") {
                continue;
            }
            tempPropertyboolCalcTag.push(propertyboolCalcTag[i]);
        }
        EstateList.loadTagData("propertyboolTag", tempPropertyboolCalcTag, "PropertyboolCalcTag");

        //var tempManagerRecommend = [];
        //for (var i = 0; i < managerRecommend.length; i++) {
        //    if (managerRecommend[i].ItemCode == "1050" || managerRecommend[i].ItemCode == "1100") {
        //        tempManagerRecommend.push(managerRecommend[i]);
        //    }           
        //}
        //EstateList.loadTagData("propertyboolTag", tempManagerRecommend, "ManagerRecommend");

    } else {

    }

    //及时搜索数据加载End

    var houseDirectionValue = '', spanPropertyType = '', expertTransaction = '';
    for (var i = 0; i < SysParam.length; i++) {
        if (SysParam[i].ParameterType == "4") {
            for (var j = 0; j < SysParam[i].Items.length; j++) {
                spanPropertyType += '<label><input type="checkbox" value="' + SysParam[i].Items[j].ItemValue + '" name="PropertyType" >' + SysParam[i].Items[j].ItemText + '</label>';
            }
        }

        if (SysParam[i].ParameterType == "8") {
            for (var j = 0; j < SysParam[i].Items.length; j++) {
                houseDirectionValue += '<label><input type="checkbox" value="' + SysParam[i].Items[j].ItemValue + '" name="HouseDirection" >' + SysParam[i].Items[j].ItemText + '</label>';
            }
        }

        if (SysParam[i].ParameterType == "115") {
            for (var j = 0; j < SysParam[i].Items.length; j++) {
                expertTransaction += '<label><input type="checkbox" value="' + SysParam[i].Items[j].ItemValue + '" name="ExpertTransaction" >' + SysParam[i].Items[j].ItemText + '</label>';
            }
        }
    }
    $('#spanHouseDirection').append(houseDirectionValue);
    $('#spanPropertyType').append(spanPropertyType);
    //行家成交
    $("#spanPropertyExpertTransaction").append(expertTransaction);

    propertyStatusMultipleCheckBox("#txtPropertyStatus", "propertyStatusSelect", PropertyStatusFilter.PropertyStatus, ['propertyType', 'hidDistrict', 'hidArea', 'roomType', 'hidBuilding']);

    //房型数据加载
    multipleCheckBox('#txtPropertyType', 'propertyType', dataBind.getRealDataByType(25), ['roomType', 'propertyStatusSelect', 'hidDistrict', 'hidArea', 'hidBuilding'], 2, '');
    multipleRegionsCheckBox('#txtDistrict', 'hidDistrict', 1, false, ['propertyStatusSelect', 'propertyType', 'roomType', 'hidBuilding'], '', '', '', $("#txtDistrictTypeKeyId").val(), 10);//城区数据加载
    multipleRegionsCheckBox('#txtArea', 'hidArea', 2, '-1', ['propertyStatusSelect', 'propertyType', 'hidDistrict', 'roomType', 'hidBuilding'], '');//片区数据加载
    $("#txtArea").focus(function () {
        //alert($("#hidArea ul").find("li").length);
        if ($("#hidArea ul").find("li").length <= 0) {
            $("#hidArea").css("display", "none");
        }
    });
    //片区数据Start
    $('#hidDistrict :checkbox[name=chbhidDistrict]').click(function () {
        var districtKeyIds = [];
        $('#hidDistrict :checkbox[name=chbhidDistrict]:checked').each(function () {
            districtKeyIds.push($(this).val());
        });
        if (districtKeyIds.length <= 0) {
            //$('#txtArea').val('片区');
        }

        multipleRegionsCheckBox('#txtArea', 'hidArea', 2, districtKeyIds, ['propertyStatusSelect', 'roomType', 'propertyType', 'hidDistrict'], '');//片区数据加载

    });
    //片区数据End

    dataBind.bindOption(53, '#btnPropertyOption');//产权性质数据加载
    dataBind.bindOption(24, '#selHouseStatus');//房屋现状数据加载
    dataBind.bindOption(38, '#selDecorationSituation');//装修情况数据加载
    dataBind.bindOption(3, '#selHouseUse');//房屋用途数据加载

    agencyVerify.nonnegativeIntInput("#intcheckinput input");
    agencyVerify.nonnegativeIntInput("#txtSquareFrom,#txtSquareTo");
    agencyVerify.zhengFuIntInput('#btnFloorFrom', false);
    agencyVerify.zhengFuIntInput('#btnFloorTo', false);
    $('#selPropertySquareType').change(function () {
        $('#txtSquareFrom').val('');
        $('#txtSquareTo').val('');
    });

    //搜索前数据处理
    $("#btnSubmit").bind("click", function () {
        //点击提交按钮显示".info-list-other"
        $(".info-list-other").show();
        //手机号不得少于
        if ($("#cmbFilterType").val() == "1" && $("#txtFilter").val().length > 0) {
            if ($("#txtFilter").val().length < 7 && $("#txtFilter").val().indexOf("*") == -1) {
                $.OKDialogAgency('<div class="tc">手机号不得少于7位</div>');
                return false;
            }
            else if ($("#txtFilter").val().length != 5 && $("#txtFilter").val().indexOf("*") == 0) {
                $.OKDialogAgency('<div class="tc">请输入手机尾号4位</div>');
                return false;
            }
        }
        var temf = $("#txtSquareFrom").val();
        var temt = $("#txtSquareTo").val();
        if (temf != "" && temt != "") {
            if (Number(temf) > Number(temt)) {
                $("#txtSquareTo").val(temf);
                $("#txtSquareFrom").val(temt);
            }
        }
        temf = $("#txtRentPriceFrom").val();
        temt = $("#txtRentPriceTo").val();
        if (temf != "" && temt != "") {
            if (Number(temf) > Number(temt)) {
                $("#txtRentPriceFrom").val(temt);
                $("#txtRentPriceTo").val(temf);
            }
        }
        temf = $("#btnFloorFrom").val();
        temt = $("#btnFloorTo").val();
        if (temf != "" && temt != "") {
            if (Number(temf) > Number(temt)) {
                $("#btnFloorFrom").val(temt);
                $("#btnFloorTo").val(temf);
            }
        }
        temf = $("#txtSalePriceFrom").val();
        temt = $("#txtSalePriceTo").val();
        if (temf != "" && temt != "") {
            if (Number(temf) > Number(temt)) {
                $("#txtSalePriceTo").val(temf);
                $("#txtSalePriceFrom").val(temt);
            }
        }
        temf = $("#txtPropertyDateFrom").val();
        temt = $("#txtPropertyDateTo").val();
        if (temf != "" && temt != "") {
            if (timehelper.parseDate(temf) > timehelper.parseDate(temt)) {
                $("#txtPropertyDateTo").val(temf);
                $("#txtPropertyDateFrom").val(temt);
            }
        }
        $("#propertyboolTag input[type=checkbox]").attr("checked", false);
    });

    //及时搜索
    $("#propertyboolTag input[type=checkbox]").bind("click", function () {
        $("#searchForm").submit();
    });

    //搜索条件的显示及隐藏
    if ($('#cmbFilterType').val() == '') {
        $('#spanCondition').css('display', 'none');
    }

    $('#cmbFilterType').change(function () {
        var cmbFilterTypeVal = $(this).val();
        if (cmbFilterTypeVal == '') {
            $('#spanCondition').css('display', 'none');
            $('#txtFilter').val('');
        } else if (cmbFilterTypeVal == '1') {
            $('#spanCondition').css('display', '');

            //$('#txtFilter').val('').attr("isint", "1");

            $('#txtFilter').attr("title", "请输入7位以上数字或者类似*3231");
        } else {
            $('#spanCondition').css('display', '');
            $('#txtFilter').val('').removeAttr("isint");
        }
    });

    //搜索日期的显示及隐藏

    $('#cmbPropertyDateType').change(function () {
        if ($(this).val() == '-1') {
            $('#spanDateTime').css('display', 'none');
            $('#txtPropertyDateFrom').val('');
            $('#txtPropertyDateTo').val('');
        } else if ($(this).val() == '5') {
            $('#spanDateTime').css('display', '');
            var myDate = new Date();
            var currentDate = myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + myDate.getDate();
            $("#txtPropertyDateTo").val(currentDate);
            $('#txtPropertyDateTo').unbind('click');
            $("#txtPropertyDateTo").click(function () {
                WdatePicker({ dateFmt: 'yyyy-MM-dd', minDate: '#F{$dp.$D(\'txtPropertyDateFrom\')}', readOnly: true });
            });
        } else {
            $('#spanDateTime').css('display', '');
            var myDate = new Date();
            var currentDate = myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + myDate.getDate();
            $("#txtPropertyDateTo").val(currentDate);
            $('#txtPropertyDateTo').unbind('click');
            $("#txtPropertyDateTo").click(function () {
                WdatePicker({ dateFmt: 'yyyy-MM-dd', minDate: '#F{$dp.$D(\'txtPropertyDateFrom\')}', maxDate: '%y-%M-%d', readOnly: true });
            });
        }
    });

    //城区片区数据End
    //盘源归属智能提示Start
    EmployeePrompt.getDepartAndEmployeeByInput('txtDepartmentName', 'hidDepartmentId', 'txtEmployeeName', 'hidUserId', false, true, 1, '业务员姓名', '请输入部门名称', true);

    //盘源归属智能提示End

    //业绩声明
    $(".performance-war-zone").bind("change", function () {
        if ($(this).val() != "-1") {
            $("#PerformanceUserName").show();
        } else {
            $("#PerformanceUserName").hide().val("");
            $("#PerformanceUserKeyId,#PerformanceDepartmentKeyId").val("");
        }
    });
    dataBind.bindOption(84, "#cmbSysParameterItemCode", true);
    $("#PerformanceUserName").autocomplete(function () {
        return "/account/GetUserListBy?name=" + escape($("#PerformanceUserName").val());
    }, {
        width: 200,
        max: 12,
        selectFirst: false,
        formatItem: function (row) {
            return row.UserName + "(" + row.EmployeeNo + ")<span style='float:right'>" + row.DepartmentName + "</span>";
        },
        formatResult: function (row) {
            return row.UserName;
        }
    }).result(function (a, b) {
        $("#PerformanceUserKeyId").val(b.UserKeyId);
        $("#PerformanceDepartmentKeyId").val(b.DepartmentKeyId);
    });

    //绑定房源审核状态
    dataBind.bindOption(108, "#cmbAuditStatus");
});

function changeDistrict(distype, distypeName, distypeCode, current) {
    $("#districtType li").removeClass("current");
    $(current).parent()[0].className = "current";
    $("#btnClear").click();
    multipleRegionsCheckBox('#txtDistrict', 'hidDistrict', 1, false, ['propertyStatusSelect', 'propertyType', 'roomType', 'hidBuilding'], '', '', '', distype, distypeCode);//城区数据加载
    $("#txtArea").focus(function () {
        if ($("#hidArea ul").find("li").length <= 0) {
            $("#hidArea").css("display", "none");
        }
    });
    //片区数据Start
    $('#hidDistrict :checkbox[name=chbhidDistrict]').click(function () {
        var districtKeyIds = [];
        $('#hidDistrict :checkbox[name=chbhidDistrict]:checked').each(function () {
            districtKeyIds.push($(this).val());
        });
        if (districtKeyIds.length <= 0) {
            //$('#txtArea').val('片区');
        }

        multipleRegionsCheckBox('#txtArea', 'hidArea', 2, districtKeyIds, ['propertyStatusSelect', 'roomType', 'propertyType', 'hidDistrict'], '');//片区数据加载

    });
    //片区数据End
    $("#txtDistrictTypeKeyId").val(distype);
    if (distypeCode == "10") {
        $("#txtIsSecondProperty").val(true);
    } else {
        $("#txtIsSecondProperty").val(false);
    }
    $("#txtDistrictType").val(distypeName);
    $("#txtDistrictTypeCode").val(distypeCode);
    $("#searchForm").submit();

}


$(function () {
    //浮动的工具栏 yjj添加
    var state = true; //存储顶部显示的状态
    $(window).scroll(function () {
        //表头排序
        $('.fixed-div div').find(".fixed-span").unbind("click");
        $('.fixed-div div').find(".fixed-span").click(function () {
            var resultVal = $(this).attr('callValue');
            if (resultVal) {
                if (resultVal.indexOf("BuildingName") > -1 || resultVal.indexOf("HouseNo") > -1) {
                    if ($("#txtEstateNames").val() != "") {
                        $('#hiddenSortValue').val(resultVal);
                        $('#searchForm').submit();
                    } else {
                        $.OKDialogAgency('<div class="tc">此项排序需要先填写楼盘名称</div>');
                    }
                } else {
                    $('#hiddenSortValue').val(resultVal);
                    $('#searchForm').submit();
                }
            }
        });
        if ($(window).scrollTop() > $("#ajaxPages").offset().top) {
            if (state) {
                //执行浮动层出现后的代码
                $(".fixed-div").show();
                $("#gdWarZoneList .thead").css("visibility", "hidden");
                $("#editToolsBox").attr("class", "float-edit-toos");
            }
            state = false;
        } else {
            if (!state) {
                //执行浮动层出现前的代码
                $(".fixed-div").hide();
                $("#gdWarZoneList .thead").css("visibility", "visible");
                $("#editToolsBox").removeAttr("class");
            }
            state = true;
        }
        $(".tab-panel-wrapper").scroll(function () {
            var l = $(".tab-panel-wrapper").scrollLeft();
            $(".fixed-div div").css("margin-left", "-" + l + "px");
        });
    });
})